package com.hotline.communication.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum CallerLevelEnum {
    BLACK(100,"黑名单"),
    GREY(0,"灰名单"),
    WHITE(1,"白名单"),
    VIP(2,"VIP"),
    SPECIAL(3,"特殊");

    /**
     * 编码
     */
    private Integer code;

    /**
     * 名称
     */
    private String name;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



    CallerLevelEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static CallerLevelEnum getCallerLevelEnum(String name){
        for (CallerLevelEnum callerLevelEnum : CallerLevelEnum.values()){
            if(callerLevelEnum.getName().equals(name)){
                return callerLevelEnum;
            }
        }
        return null;
    }

    public static CallerLevelEnum getCallerLevelEnum(Integer code){
        for (CallerLevelEnum callerLevelEnum : CallerLevelEnum.values()){
            if(callerLevelEnum.getCode().equals(code)){
                return callerLevelEnum;
            }
        }
        return null;
    }

    public static List getCallerLevelEnumList(){
        List list = new ArrayList();
        for (CallerLevelEnum callerLevelEnum : CallerLevelEnum.values()){
            Map map = new HashMap<>();
            map.put("code",callerLevelEnum.getCode());
            map.put("name",callerLevelEnum.getName());
            list.add(map);
        }
        return list;
    }

    public static List<String> getCallerLevelNames(){
        List<String> list = new ArrayList();
        for (CallerLevelEnum callerLevelEnum : CallerLevelEnum.values()){
            list.add(callerLevelEnum.getName());
        }
        return list;
    }
}
